package com.fqr;

import java.io.File;

import org.apache.log4j.Logger;

public abstract class OutgoingJob extends FlexJob {

	Logger logger = Logger.getLogger(OutgoingJob.class);

	private Destination destination;

	public Destination getDestination() {
		return destination;
	}

	public void setDestination(Destination destination) {
		this.destination = destination;
	}

	public void runJob() throws Exception {
		String filename = execute();
		if (filename == null || filename.trim().length() == 0)
			logger.warn("No outfile is generated");
		else {
			logger.info("Send " + new File(filename).getAbsolutePath() + " to "
					+ destination.getName());
			destination.send(filename);
		}
	}

	protected abstract String execute() throws Exception;

}
